package no.mehdi.usereg.core.repository.impl;

import java.util.List;

import no.mehdi.usereg.core.domain.Person;
import no.mehdi.usereg.core.repository.PersonRepository;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.transaction.annotation.Transactional;

public class PersonRepositoryImpl extends HibernateDaoSupport implements PersonRepository{
	
	@Override
	@Transactional
	public void savePerson(final Person person) {
		getHibernateTemplate().saveOrUpdate(person);
	}

	@SuppressWarnings("unchecked")
	@Override
	@Transactional(readOnly=true)
	public List<Person> getPersonByName(String name) {
		return getHibernateTemplate().find("from Person where name=?",name);
	}
	@SuppressWarnings("unchecked")
	@Override
	@Transactional(readOnly=true)
	public List<Person> getPersonByTagId(String rfidTag) {
		return getHibernateTemplate().find("from Person where rfidTag=?",rfidTag);
	}

	@SuppressWarnings("unchecked")
	@Override
	@Transactional(readOnly=true)
	public List<Person> getAllEnteries() {
		return getHibernateTemplate().find("from Person");
	}

		

}
